From 5093100b83de7056827679fe0014ea75e190a070 Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Sun, 19 Nov 2017 15:09:03 -0700 Subject: [PATCH] work around QXmlStreamReader issue on windows. --- gpx.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gpx.cc b/gpx.cc index a5a390005..7a4cc63c5 100644 --- a/gpx.cc +++ b/gpx.cc @@ -1375,6 +1375,22 @@ gpx_read() gpx_cdata(reader->text().toString()); break; +// On windows with input redirection we can read an Invalid token +// after the EndDocument token. This also will set an error +// "Premature end of document." that we will fatal on below. +// This occurs with Qt 5.9.2 on windows when the file being +// sent to stdin has dos line endings. +// This does NOT occur with Qt 5.9.2 on windows when the file being +// sent to stdin has unix line endings. +// An example of a problematic file is reference/basecamp.gpx, +// which fails on windows with this invocation from a command prompt: +// .\GPSBabel.exe -i gpx -f - < reference\basecamp.gpx +// This was demonstrated on 64 bit windows 10. Other versions of +// windows and Qt likely fail as well. +// To avoid this we quit reading when we see the EndDocument. +// This does not prevent us from correctly detecting the error +// "Extra content at end of document." + case QXmlStreamReader::EndDocument: case QXmlStreamReader::Invalid: atEnd = true; break; -- 2.30.2